<ui:composition template="/WEB-INF/templates/showcase.xhtml"
	xmlns="http://www.w3.org/1999/xhtml"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:o="http://omnifaces.org/ui"
>
	<ui:define name="description">
		<p>
			The <code>omnifaces.SelectItemsIndexConverter</code> allows you to populate e.g. a drop-down with complex Java
			model objects as value of <code>&lt;f:selectItems&gt;</code> and have JSF convert those automatically back
			without the need to provide a custom converter which may need to do the job based on possibly expensive
			service/DAO operations.
        </p>
        <p>
            Use the SelectItemsIndexConverter rather than the SelectItemsConverter if you don't wan't to make the selection
            based on the <code>toString()</code> method of your Java Data/Model objects. Thus you don't need to modify your existing classes.
		</p>
        <p>
            Using the SelectItemsIndexConverter you don't need to provide an unique identifier in your data objects.
        </p>
		<p>
			For examples:
		</p>
	</ui:define>
	<ui:define name="demo">
		 <h:form>
			<p>
				<h:outputText id="selected_item1" value="Last selected item: #{selectItemsIndexBean.selectedEntity.value}" />
			</p>

             <p>
                 <h:outputText id="selected_item2" value="Last selected user: #{selectItemsIndexBean.selectedExampleUserData.eMail}" />
             </p>
			<h:panelGrid columns="2">
				<h:outputLabel for="indexContverterExample1" value="Entity List with SelectItemsIndexConverter: " />
				<h:selectOneMenu id="indexContverterExample1" value="#{selectItemsIndexBean.selectedEntity}" converter="omnifaces.SelectItemsIndexConverter">
					<f:selectItem itemLabel="Choose item" noSelectionOption="true" />
					<f:selectItems value="#{selectItemsIndexBean.exampleEntities}" var="entity" itemLabel="#{entity.value}" />
					<f:ajax render="selected_item1" />
				</h:selectOneMenu>

                <h:outputLabel for="indexContverterExample2" value="DTO List with SelectItemsIndexConverter: " />
                <h:selectOneMenu id="indexContverterExample2" value="#{selectItemsIndexBean.selectedExampleUserData}" converter="omnifaces.SelectItemsIndexConverter">
                    <f:selectItem itemLabel="Choose item" noSelectionOption="true" />
                    <f:selectItems value="#{selectItemsIndexBean.exampleUserDataList}" var="userData" itemLabel="#{userData.userName} - #{userData.eMail}" />
                    <f:ajax render="selected_item2" />
                </h:selectOneMenu>
			</h:panelGrid>
		</h:form>
	</ui:define>
</ui:composition>